<?php

use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Log Channel
    |--------------------------------------------------------------------------
    |
    | This option defines the default log channel that gets used when writing
    | messages to the logs. The name specified in this option should match
    | one of the channels defined in the "channels" configuration array.
    |
    */

    'default' => env('LOG_CHANNEL', 'stack'),

    /*
    |--------------------------------------------------------------------------
    | Log Channels
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log channels for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Drivers: "single", "daily", "slack", "syslog",
    |                    "errorlog", "monolog",
    |                    "custom", "stack"
    |
    */

    'channels' => [
        'stack' => [
            'driver'            => 'stack',
            'channels'          => ['single'],
            'ignore_exceptions' => false,
        ],

        'single' => [
            'driver' => 'single',
            'path'   => storage_path('logs/laravel.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
        ],

        'daily' => [
            'driver' => 'daily',
            'path'   => storage_path('logs/laravel.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'days'   => 7,
        ],

        'slack' => [
            'driver'   => 'slack',
            'url'      => env('LOG_SLACK_WEBHOOK_URL'),
            'username' => 'Laravel Log',
            'emoji'    => ':boom:',
            'level'    => env('LOG_LEVEL', 'critical'),
        ],

        'papertrail' => [
            'driver'       => 'monolog',
            'level'        => env('LOG_LEVEL', 'debug'),
            'handler'      => SyslogUdpHandler::class,
            'handler_with' => [
                'host' => env('PAPERTRAIL_URL'),
                'port' => env('PAPERTRAIL_PORT'),
            ],
        ],

        'stderr' => [
            'driver'    => 'monolog',
            'level'     => env('LOG_LEVEL', 'debug'),
            'handler'   => StreamHandler::class,
            'formatter' => env('LOG_STDERR_FORMATTER'),
            'with'      => [
                'stream' => 'php://stderr',
            ],
        ],

        'syslog' => [
            'driver' => 'syslog',
            'level'  => env('LOG_LEVEL', 'debug'),
        ],

        'errorlog' => [
            'driver' => 'errorlog',
            'level'  => env('LOG_LEVEL', 'debug'),
        ],

        'null' => [
            'driver'  => 'monolog',
            'handler' => NullHandler::class,
        ],

        'emergency' => [
            'path' => storage_path('logs/laravel.log'),
        ],

        'pay' => [
            'driver' => 'daily',
            'path'   => storage_path('logs/pay.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'days'   => 7,
        ],

        'order' => [
            'driver' => 'custom',
            'path'   => storage_path('logs'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'via'    => \App\Kuafu\Order\Logging\OrderCustomLogger::class,
            'days'   => 14,
        ],

        'mybank' => [
            'driver' => 'custom',
            'path'   => storage_path('logs'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'via'    => \App\Kuafu\Mybank\Logging\MybankCustomLogger::class,
            'days'   => 14,
        ],

        'orderSyncSingle' => [
            'driver' => 'single',
            'path'   => storage_path('logs/orderSync.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
        ],
        'mqtt'            => [
            'driver' => 'daily',
            'path'   => storage_path('logs/mqtt.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'days'   => 7,
        ],
        'apiAccess'       => [
            'driver' => 'daily',
            'path'   => storage_path('logs/apiAccess.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'days'   => 7,
        ],
        'douyin'       => [
            'driver' => 'daily',
            'path'   => storage_path('logs/douyin.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'days'   => 7,
        ],
        'waiMai'          => [
            'driver' => 'daily',
            'path'   => storage_path('logs/waiMai.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'days'   => 3,
        ],
        'wechat'          => [
            'driver' => 'daily',
            'path'   => storage_path('logs/wechat.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'days'   => 7,
        ],

        'invoice'       => [
            'driver' => 'daily',
            'path'   => storage_path('logs/invoice.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'days'   => 7,
        ],

        // 记录MySQL日志
        'sql'           => [
            'driver' => 'daily',
            'path'   => storage_path('logs/sql.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'days'   => 3,
        ],

        //神策
        'sensors'       => [
            'driver' => 'daily',
            'path'   => storage_path('logs/sensors.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'days'   => 7,
        ],
        //远程请求日志
        'remoteRequest' => [
            'driver' => 'daily',
            'path'   => storage_path('logs/remoteRequest.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
            'days'   => 3,
        ],
    ],

    'query' => [
        'enabled'     => env('LOG_QUERY', env('APP_ENV') === 'local'),

        // Only record queries that are slower than the following time
        // Unit: milliseconds
        'slower_than' => 0,

        // Only record queries when the QUERY_LOG_TRIGGER is set in the environment,
        // or when the trigger HEADER, GET, POST, or COOKIE variable is set.
        'trigger'     => env('QUERY_LOG_TRIGGER'),

        // Log Channel
        'channel'     => 'sql',
        // 只记录这些开头的sql,空字符串的时候，记录所有的SQL
        'only_prefix' => env('LOG_ONLY_PREFIX', 'insert,update,delete'),
    ],

];
